
package com.bobo.mall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


import java.io.IOException;

/**
 * @program: malll
 * @description:
 * @author: Mr.Xu
 * @create: 2021-01-31 14:04
 **/
@Configuration
public class MyRedissonConfig {

    /**
     * 所有对Redisson 的使用都是通过 RedissonClient 对象
     * @return
     * @throws IOException
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson() throws IOException {
        // 创建配置
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.68.131:6379");
        //config.useClusterServers().addNodeAddress("");  // 集群模式
        // 根据 config ，创建出 RedissonClient 示例
        return Redisson.create(config);
    }
}